home *** CD-ROM | disk | FTP | other *** search
- if !?argv[1]
- label usage
- echo usage: octal number
- exit 10
- endif
- if !numeric(argv[1])
- goto usage
- endif
- local number result
- if number=argv[1]
- result=""
- else
- result="0"
- endif
- while number
- result=cat(number&7,"$result"),number=(number>>3)&0x1fffffff
- endwhile
- echo $result
- exit 0
- # Octal - convert a decimal number to an octal string. Normally, strings
- # which contain only digits are considered to be numeric and are
- # therefore subject to loss of leading zeros; this is why result is
- # quoted in the loop.
- # Octal is presented as is; no warrantee is either expressed or implied
- # as to it's suitability to any purpose whatsoever. You assume all the
- # risk for all damage, even if caused by a defect in the software, no
- # matter how awful.
-